﻿c0da_convert_holding_interaction = {
	category = interaction_category_uncategorized
	hidden = yes
	
	desc = c0da_convert_holding_interaction_desc
	
	target_type = title
	target_filter = actor_domain_titles
	
	auto_accept = yes
	
	special_interaction = feudalize_tribal_holding

	has_valid_target_showing_failures_only = {
		has_game_rule = c0da_holding_conversion_on 
		scope:actor = scope:target.county.holder
		exists = scope:target
		scope:target = {
			exists = title_province
			title_province = {
				OR = {
					has_holding_type = city_holding
					has_holding_type = castle_holding
					has_holding_type = church_holding
				}
			}
		}
	}
	
	send_option = {
		is_valid = {
			exists = scope:target
			scope:target = {
				exists = title_province
				title_province = { c0da_eligible_for_holding_conversion = { TARGET_TYPE = castle_holding } }
			}
		}		
		flag = castle_holding
		localization = convert_holding_castle_interaction_desc
	}
	
	send_option = {
		is_valid = {
			exists = scope:target
			scope:target = {
				exists = title_province
				title_province = { c0da_eligible_for_holding_conversion = { TARGET_TYPE = city_holding } }
			}
		}		
		flag = city_holding
		localization = convert_holding_city_interaction_desc
	}
	
	send_option = {
		is_valid = {
			exists = scope:target
			scope:target = {
				exists = title_province
				title_province = { c0da_eligible_for_holding_conversion = { TARGET_TYPE = church_holding } }
			}
		}		
		flag = church_holding
		localization = convert_holding_church_interaction_desc
	}
	
	cost = {
		gold = {
			value = c0da_convert_holding_interaction_cost
		}
	}
	
	on_accept = {
		scope:target.title_province = { c0da_church_holding_destruction_costs = yes }
		if = {
			limit = { scope:castle_holding = yes }
			scope:target.title_province = {
				set_holding_type = castle_holding
			}
		}
		else_if = {
			limit = { scope:city_holding = yes }
			scope:target.title_province = {
				set_holding_type = city_holding
			}
		}
		else_if = {
			limit = { scope:church_holding = yes }
			scope:target.title_province = {
				set_holding_type = church_holding
				c0da_church_holding_construction_benefits = yes
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}